package com.kktestspb.demo.controller;


import com.kktestspb.demo.polo.User;
import com.kktestspb.demo.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 用户user服务
 * 注册以及登陆服务
 */
@RestController
public class UserController {
    @Autowired
    UserServices userServices;

    @GetMapping("/getUserList")
    public List<User> getUserlist(){
        return userServices.getUserList();
    }
    @GetMapping("/getUserById/{id}")
    public User getUserById(@PathVariable("id")String id){
        return userServices.getUserById(id);
    }
    @PutMapping("/updateUser")
    public void updateUser(User user){
       // System.out.println(user.toString());
        userServices.updateUser(user);
    }
    @DeleteMapping("/delUser/{id}")
    public void deleteUser(@PathVariable("id")String id){
        userServices.deleteUser(id);
    }

    @PostMapping("/addUser")
    public void addUser(User user){
        userServices.addUser(user);
    }


}
